package com.stars.easyms.logger.support.logback.pattern;

import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.pattern.DateConverter;
import ch.qos.logback.classic.pattern.LoggerConverter;
import com.stars.easyms.logger.support.EasyMsOverride;
import com.stars.easyms.logger.support.logback.pattern.converter.EasyMsDateConverter;
import com.stars.easyms.logger.support.logback.pattern.converter.EasyMsNamedConverter;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * <p>className: EasyMsPatternLayout</p>
 * <p>description: 重写PatternLayout类</p>
 *
 * @author guoguifang
 * @date 2019-08-21 14:46
 * @since 1.3.0
 */
public final class EasyMsPatternLayout extends PatternLayout implements EasyMsOverride {

    private static final Map<String, String> CONVERT_MAP = new LinkedHashMap<>(8);

    static {
        CONVERT_MAP.put(DateConverter.class.getName(), EasyMsDateConverter.class.getName());
        CONVERT_MAP.put(LoggerConverter.class.getName(), EasyMsNamedConverter.class.getName());
        defaultConverterMap.forEach((key, value) ->
                CONVERT_MAP.forEach((key1, value1) -> {
                    if (value.equals(key1)) {
                        defaultConverterMap.put(key, value1);
                    }
                })
        );
    }
}